package com.sgcc.fj.pmos.e_fj_home.adapter;

import android.content.Context;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.sgcc.pmos.nativesdk.R;
import com.sgcc.fj.pmos.e_fj_home.bean.UserTypeListBean;

public class UserTypeAdapter extends BaseQuickAdapter<UserTypeListBean.DataDTO, BaseViewHolder> {

    private Context mContext;

    public UserTypeAdapter(Context context) {
        super(R.layout.item_usertype);
        mContext = context;
    }

    public interface OnItemClickListener {
        //条目点击
        void itemClickListener(int position, UserTypeListBean.DataDTO bean);
    }

    private OnItemClickListener mOnItemClickListener;

    public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
        this.mOnItemClickListener = onItemClickListener;
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, UserTypeListBean.DataDTO bean) {
        baseViewHolder.setText(R.id.tv_time, bean.getMonth());
        baseViewHolder.setText(R.id.tv_endtime, bean.getEndmonth());
        baseViewHolder.setText(R.id.tv_usertype, getUserType(bean.getUserType()));
    }


    public static String getUserType(String typeNum) {
        String userType = "";
        switch (typeNum) {
            case "1":
                userType = "直接交易用户";
                break;
            case "2":
                userType = "零售用户";
                break;
            case "3":
                userType = "电网公司代理用户（1.0 倍）";
                break;
            case "4":
                userType = "电网公司代理用户（1.5 倍)";
                break;
        }
        return userType;
    }
}
